package com.atjava.webspider.logic;

import java.util.List;

import com.atjava.webspider.model.DefaultResource;
import com.atjava.webspider.model.Resource;
import com.atjava.webspider.model.Task;
import com.atjava.webspider.util.RegexpUtil;

public class ResourceLogic {

	private Task task;
	
	public List<String> getResourceUrls(String content,Resource res){
		DefaultResource defResource = getDefaultResource(res);
		return RegexpUtil.getGroupList(content, defResource.getRegexp(), defResource.getGroupNum());
	}
	
	public DefaultResource getDefaultResource(Resource res){
		List<DefaultResource> defResources = ConfigLogic.getAppConfig().getResources();
		return (DefaultResource)CommonLogic.getByName(defResources, res.getName());
	}
	
	public ResourceLogic(Task task){
		this.task = task;
	}
	
/*	public void deleteResource(String name){
		//output
		List<Resource> resources = task.getResources();
		//pattern
		for(int i=0;i<resources.size();i++){
			Resource res = resources.get(i);
			if(name.equals(res.getName())){
				resources.remove(i);break;
			}
		}
	}*/
	
	public static void main(String[] args) {
		
		//System.err.println(new ResourceLogic().getFileAbsPath("html"));
		
	}
	
}
